//漂浮的纵向位置变化效果

cc.Class({
    extends: cc.Component,

    properties: {
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        this.startFloat = true
        this.startPos =cc.v2(this.node.x,this.node.y)
        this.time = 0
        this.period = 3
        this.float()
    },
    float(pos,period,phase) {
        this.startFloat = true
        this.phase = phase?phase:0
        if(pos){
            this.startPos = pos
        }
        if(period){
            this.period = period
        }
        
    },
    stop(){
        this.startFloat =false
        this.node.y = this.startPos.y
    },
    update (dt) {
        if(this.startFloat){
            this.time += dt
            this.node.y = this.startPos.y + Math.sin(this.time*2 *3.1415926 /this.period + this.phase) * this.node.height /10
        }
    },
});
